package com.job.liushuang.HomeWork0716;

import java.util.Random;

/**
 * @author Liushuang
 * @version 1.0
 * @since 2022-07-16 19:23:57
 */
public class sbfEX01 {
    public static void main(String[] args) {
        Random ran=new Random();
        String letters="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        long millis=System.currentTimeMillis();
        System.out.println(millis); //1657955383196
        StringBuffer sbf =new StringBuffer(String.valueOf(millis)); //millis+""
        int insertIndex=2;
        for (int i = 1; i<=5 ; i++) {
            sbf.insert(insertIndex,letters.charAt(ran.nextInt(letters.length())));
            insertIndex+=3;
        }
        System.out.println(sbf.toString());

        String str="iu7i8csr83sdf9";
        StringBuffer sbf2=new StringBuffer(str);
        StringBuffer num=new StringBuffer();//存放每一个数字字符
        for (int i = 0; i <sbf2.length() ; i++) {
            char ci=sbf2.charAt(i);
            if (Character.isDigit(ci)){
                num.append(ci);
            }
        }
        int i=Integer.parseInt(num.toString());
        System.out.println(i);


        /**
         * String,StringBuffer,StringBuilder
         * String是固定长度字符串，原因内部保存字符的数组是final修饰，本质是常量
         * StringBuffer，StringBuilder是可变长度字符串，原因内部保存字符的数组不是final修饰，可以重新指向数组
         * StringBuffer是线程安全的
         * StringBuilder是线程不安全的
         * StringBuffer和StringBuilder API是一样的
         * 效率是： String < StringBuffer < StringBuilder
         */
    }
}
